package com.petecat.interchan.base.warning.empl.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.petecat.interchan.base.warning.empl.service.IWarningEmplService;
import com.petecat.interchan.core.constans.Global;
import com.petecat.interchan.core.controller.BaseController;
import com.petecat.interchan.protocol.GlobalHeader;
import com.petecat.interchan.protocol.Result;
import com.petecat.interchan.protocol.base.empl.dto.BsWarningEmplQryDTO;
import com.petecat.interchan.protocol.base.empl.vo.BsWarningEmplTreeVO;
import com.petecat.interchan.protocol.data.PageVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@Api("预警人员管理")
@RequestMapping("/base/warningempl")
public class WarningEmplController extends BaseController{
	
	@Autowired
	private IWarningEmplService emplService;
	
	@SuppressWarnings("unchecked")
	@ApiOperation("TREE查询预警人员")
	@GetMapping("/queryWarningEmplTree")
	public Result<PageVO<BsWarningEmplTreeVO>> queryWarningEmplTree(@ModelAttribute BsWarningEmplQryDTO bsWarning,
			@ApiIgnore @RequestHeader(name = Global.GLOBAL_HEADER, required = false) String header) {
		GlobalHeader userInfo = this.getUserInfo(header, true);
		bsWarning.setUserId(userInfo.getUserId());
		PageVO<BsWarningEmplTreeVO> pageVO = emplService.queryWarningEmplTree(bsWarning);
		return (Result<PageVO<BsWarningEmplTreeVO>>) Result.ok(pageVO);
	}
	
	
	@ApiOperation("导出每个项目启动规则的预警人员信息到Excel")
	@GetMapping("/outOpenRuleEmplInfo")
	public ResponseEntity<byte []> outOpenRuleEmplInfo() {
//		@ApiIgnore @RequestHeader(name = Global.GLOBAL_HEADER, required = false) String header
		return emplService.outOpenRuleEmplInfo("1");
	}
	
	
}
